"use strict";
/**
 * 定义一个学生数组
 * 学生：编号、名字、性别、班级
 */
Object.defineProperty(exports, "__esModule", { value: true });
var students = [
    {
        id: 1, name: "杜欣", gender: "女", phone: "344", classes: {
            cid: 1, name: "web35"
        }
    },
    {
        id: 2, name: "袁令", gender: "男", classes: {
            cid: 2, name: "web34"
        }
    },
    {
        id: 3, name: "童瑶", gender: "女", classes: {
            cid: 3, name: "web33"
        }
    }
];
function getValue(students, search) {
    var stu = students.find(function (item) { return item.name == search; });
    return stu;
}
var result = getValue(students, "童瑶");
//?.是一种新的运算符，ES2020这个版本推出来。 可选链运算符
// result是undefined或者null的时候 不会.id
console.log(result === null || result === void 0 ? void 0 : result.id);
/**
 * 获取学生电话
 */
function getPhone(students, id) {
    var stu = students.find(function (item) { return item.id == id; });
    return stu === null || stu === void 0 ? void 0 : stu.phone;
}
getPhone(students, 1);
